﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Elysium.Demo;
using SIIE_ERP.Codigo;
using SIIE_ERP.View;
using SIIE_ERP.BaseDatos;
using Elysium.Demo.Controls;

namespace Elysium.Demo.Informes
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class Seleccion_Inventarios_MovimientosPorArticulo : UserControl
    {
        private UsuarioActivo _sesion;
        private string _RutaReporte;
        bool IsReportEmbedded;

        public Seleccion_Inventarios_MovimientosPorArticulo(ref UsuarioActivo usuario, string RutaReporte, bool IsReportEmbedded = false)
        {
            InitializeComponent();
            this._sesion = usuario;
            this._RutaReporte = "Informes/Reportes/Operativos/Inventarios/MovsInventario2.rdlc";
            
            CargarCombos();

            if (IsReportEmbedded)
                ButtonRegresar.Visibility = System.Windows.Visibility.Hidden;
            this.IsReportEmbedded = IsReportEmbedded;
        }

        public void CargarCombos()
        {
            ComboBoxUI.ComboArticulos_AutoComplete_Inventarios(ref Combo_ArticulosAutoComplete, this._sesion, "");
            ComboBoxUI.ComboTiempo(ref Combo_Tiempo);            
        }

        private void ButtonRegresar_Click(object sender, RoutedEventArgs e)
        {
            Viewbox Aux = (Viewbox)this.Parent;
            Aux.Child = null;
            Aux.Child = new Menu_Informes(ref _sesion);           
        }

        private void Button_Aceptar_Click_1(object sender, RoutedEventArgs e)
        {
            
            int Tiempo = Int32.Parse(((CItem)Combo_Tiempo.SelectedItem).Id);

            int Id_Articulo = 0;

            try
            {
                Id_Articulo = Int32.Parse(((CAutocomplete)Combo_ArticulosAutoComplete.SelectedItem).Id);
            }
            catch (Exception)
            {
                MessageBox.Show("Favor de seleccionar un Artículo");
                return;
            }
            
            Viewbox Aux = (Viewbox)this.Parent;
            Aux.Child = null;
            Aux.Child = new GenericReport(ref _sesion, _RutaReporte, Tiempo, Id_Articulo);   
        }        
    }
}

